<!-- <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const arr=[1,2,3,4]
        console.dir(arr.__proto__);
    </script>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <script>
        const properties = [
        "中华园,北京市,公寓",
        "华景苑,上海市,别墅",
        "新城市广场,深圳市,公寓",
        "雅居乐花园,广州市,别墅",
        "恒大城,广州市,公寓",
        "太阳花园,北京市,别墅"
        ];
  

        function fn(properties){
            // 创建一个新对象
        const obj={}
            // 把每一项全部转成数组，并且删除第二项
        const arr = properties.map((item)=>item.split(',').splice(0,1).concat(item.split(',').splice(2,1)))
            // 把房子类型为公寓的筛选出来
        const newArr = arr.filter((item)=>item[1]==='公寓')
            // 把房子类型为别墅的筛选出来
        const newArr1 = arr.filter((item)=>item[1]==='别墅')
        const a = newArr.map((item)=>item.splice(0,1).join(','))
        const b = newArr1.map((item)=>item.splice(0,1).join(','))
            console.log(newArr);
            // console.log(a);
        newArr.forEach((item)=>obj[item.join('')]=a)
        newArr1.forEach((item)=>obj[item.join('')]=b)
        console.log(obj);
        }
        fn(properties)
    </script>
</body>
</html>